﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class cookie : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        HttpCookie cookie = new HttpCookie("message");
        cookie.Value = this.TextBox1.Text;
        cookie.Expires = DateTime.Now.AddMinutes(10.0);
        cookie.Domain = "www.microsoft.com";

        this.Response.Cookies.Add(cookie);
    }
    protected void LinkButton2_Click(object sender, EventArgs e)
    {
        HttpCookie cookie = this.Request.Cookies["message"];
        if (cookie != null)
        {
            this.Label1.Text = cookie.Value;
        }
    }
    protected void LinkButton3_Click(object sender, EventArgs e)
    {
        HttpCookie cookie = this.Request.Cookies["message"];
        cookie.Expires = new DateTime( 1999, 1,1);

        this.Response.Cookies.Add( cookie);

    }
}